//
//  UnionShapeScene.h
//  Ray Tracer
//
//  Created by Kaila, Ashish on 4/7/13.
//  Copyright (c) 2013 Kaila, Ashish. All rights reserved.
//

#ifndef Ray_Tracer_UnionShapeScene_h
#define Ray_Tracer_UnionShapeScene_h

void renderUnionShapeScene(Raytracer& raytracer,
                           int width,
                           int height,
                           bool enableSpecular)
{
    // Camera parameters.
	Point3D eye(0, 0, 1);
	Vector3D view(0, 0, -1);
	Vector3D up(0, 1, 0);
	double fov = 60;
    
	// Defines a material for shading.
	SolidMaterial gold( Colour(0.3, 0.3, 0.3), Colour(0.75164, 0.60648, 0.22648),
                       Colour(0.628281, 0.555802, 0.366065),
                       51.2,
                       0,
                       0,
                       0);
    
	SolidMaterial jade( Colour(0, 0, 0), Colour(0.54, 0.89, 0.63),
                       Colour(0.316228, 0.316228, 0.316228),
                       12.8,
                       0,
                       0,
                       0);
    
	// Defines a point light source.
	raytracer.addLightSource( new PointLight(Point3D(0, 0, 5),
                                             Colour(0.9, 0.9, 0.9) ),
                             enableSpecular);
	
	/*SceneDagNode* plane = raytracer.addObject( new UnitSquare(), &jade );
    SceneObject* planeObj = plane->obj;
	planeObj->translate(Vector3D(0, 0, -7));
	//planeObj->rotate('x', -45);
    double factor1[3] = { 6.0, 6.0, 6.0 };
	planeObj->scale(Point3D(0, 0, 0), factor1);*/
    
    // Add a unit square into the scene with material mat.
    UnitSphere* bottleSphere = new UnitSphere(&jade);
    bottleSphere->translate(Vector3D(0, 0, 1.1));
    
    UnitCylinderShape* bottleNose = new UnitCylinderShape(&jade);
    double noseFactor[3] = {0.25, 0.25, 1};
    bottleNose->scale(Point3D(), noseFactor);
    bottleNose->translate(Vector3D(0, 0, 2.5));
    
    UnitCylinderShape* bottleTrunk = new UnitCylinderShape(&gold);
    double trunkFactor[3] = {1, 1, 2.5};
    bottleTrunk->scale(Point3D(), trunkFactor);
    
    UnionShape* bottleShape = new UnionShape();
    bottleShape->addChildShape(bottleSphere);
    bottleShape->addChildShape(bottleTrunk);
    bottleShape->addChildShape(bottleNose);
    bottleShape->translate(Vector3D(0, -0.3, -5));
    bottleShape->rotate('x', -90);
    raytracer.addObject(bottleShape);
    
    UnitCubeShape cube(&gold);
    double cubeScale[] = {0.5, 0.5, 0.5};
    cube.scale(Point3D(), cubeScale);
    //cube.rotate('y', 30);
    //cube.rotate('x', 30);
    cube.translate(Vector3D(1, 0, -0.5));
    raytracer.addObject(&cube);
    
	// Render the scene, feel free to make the image smaller for
	// testing purposes.
	raytracer.render(width, height, eye, view, up, fov, "unionshape1.bmp");
	
	// Render it from a different point of view.
    Point3D eye2(4, 2, 1);
	Vector3D view2(-4, -2, -6);
	//raytracer.render(width, height, eye2, view2, up, fov, "unionshape2.bmp");
}

#endif
